import { sync } from 'cross-spawn';
import { existsSync } from 'fs';
import { join } from 'path';

export default async function initHusky(packageManager, projectRoot) {
  const gitPath = join(projectRoot, '.git');
  if (!existsSync(gitPath)) {
    sync(`git`, ['init'], { cwd: projectRoot, stdio: 'inherit' });
  }
  // const path = join(projectRoot, '/.husky/');
  // mkdirSync(path, { recursive: true });
  //  //install(path);
  // const cmd=packageManager==='npm'?['husky','init']:['exec','husky','init']
  //  sync(`npx`, cmd, { cwd: projectRoot, stdio: 'inherit' });

  //  set(join(path, 'pre-commit'), 'npm run lint-staged');
  //  set(join(path, 'commit-msg'), 'npx --no-install commitlint --edit $1');
}
